<template>
  <div>
    <el-card style="min-width: 1200px">
      <div class="tableSelectWrap">
        <el-form
          ref="errorHandleForm"
          :model="commandForm"
          label-width="100px"
          style="margin-bottom: -20px"
        >
          <el-row>
            <el-col :span="7">
              <el-form-item label="选择时间" prop="date">
                <el-date-picker
                  style="width: 100%"
                  v-model="commandForm.date"
                  :default-time="['00:00:00', '23:59:59']"
                  type="daterange"
                  range-separator="至"
                  start-placeholder="开始日期"
                  end-placeholder="结束日期"
                  value-format="yyyy-MM-dd"
                >
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="7" :offset="1">
              <el-form-item label="支付渠道" prop="payformChannel">
                <el-select
                  v-model="commandForm.payformChannel"
                  class="leftSelect"
                  style="width: 100%"
                  placeholder="请选择支付渠道"
                >
                  <el-option
                    v-for="(item, index) of payChannel"
                    :key="index"
                    :label="item.label"
                    :value="item.value"
                  ></el-option>
                </el-select>
              </el-form-item>
   
            </el-col>
            <el-col :span="7" :offset="1" style="min-width: 170px">
              <el-button
                class="width120"
                @click="
                  () => {
                    resetForm('errorHandleForm');
                    payChannelTypeList = [];
                  }
                "
                >重置</el-button
              >
              <el-button
                type="primary"
                class="width120"
                @click="
                  () => {
                    this.dataForm = JSON.parse(
                      JSON.stringify(this.commandForm)
                    );
                    this.handleQuery();
                  }
                "
                >查询</el-button
              >
            </el-col>
          </el-row>
        </el-form>
      </div>
    </el-card>
    <el-card style="margin-top: 15px; min-width: 1200px">
      <div class="switch">
        <el-switch v-model="isFixedTableH" inactive-text="固定表头">
        </el-switch>
      </div>
      <el-table :height="fixedTableHeight" :data="dataList">
        <template slot="empty">
          <el-empty
            :image="require('@/assets/imgs/middleWork/k1.png')"
            :image-size="80"
            description="暂无相关数据"
          ></el-empty>
        </template>
        <el-table-column
          show-overflow-tooltip
          prop="billDate"
          align="center"
          label="交易日期"
        >
          <template slot-scope="scope">
            <div
              style="
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
              "
            >
              {{ scope.row.billDate ? scope.row.billDate : "-" }}
            </div>
          </template>
        </el-table-column>
        <el-table-column
          show-overflow-tooltip
          prop="billTypeName"
          align="center"
          label="账单类型"
        >
          <template slot-scope="scope">
            <div
              style="
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
              "
            >
              {{ scope.row.billTypeName ? scope.row.billTypeName : "-" }}
            </div>
          </template>
        </el-table-column>
        <el-table-column
          show-overflow-tooltip
          prop="innerPayformNo"
          align="center"
          label="流水号"
        >
          <template slot-scope="scope">
            <div
              style="
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
              "
            >
              {{ scope.row.innerPayformNo ? scope.row.innerPayformNo : "-" }}
            </div>
          </template>
        </el-table-column>
        <el-table-column
          show-overflow-tooltip
          prop="amount"
          align="center"
          label="金额/元"
        >
          <template slot-scope="scope">
            <div
              style="
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
              "
            >
              {{ scope.row.amount ? scope.row.amount : "0.00" }}
            </div>
          </template>
        </el-table-column>
        <el-table-column
          show-overflow-tooltip
          prop="errorMsg"
          align="center"
          label="差错类型"
        >
          <template slot-scope="scope">
            <div
              style="
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
              "
            >
              {{ scope.row.errorMsg ? scope.row.errorMsg : "-" }}
            </div>
          </template>
        </el-table-column>
        <el-table-column
          show-overflow-tooltip
          prop="handleStatusName"
          align="center"
          label="处理状态"
        >
          <template slot-scope="scope">
            <div
              style="
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
              "
            >
              {{
                scope.row.handleStatusName ? scope.row.handleStatusName : "-"
              }}
            </div>
          </template>
        </el-table-column>
        <el-table-column show-overflow-tooltip align="center" label="操作">
          <template slot-scope="scope">
            <el-button
              type="text"
              @click="submit(scope.row)"
              v-if="scope.row.handleStatusName == '待处理'"
              >提交差错处理工单</el-button
            >
            <div v-else>-</div>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
    <el-pagination
      layout="prev, pager, next, sizes, jumper"
      :page-sizes="[10, 20, 30, 40]"
      :page-size="pageSize"
      :current-page="pageNum"
      :total="total"
      @current-change="pageCurrentChangeHandle"
      @size-change="pageSizeChangeHandle"
    >
    </el-pagination>

    <el-dialog
      :visible.sync="visible"
      :show-close="false"
      top="30vh"
      width="30%"
    >
      <div class="dialogText">
        <i class="el-icon-warning"></i>
        <div>
          <div class="dialogTitle">确认提交差错处理至云尘付？</div>
          <div class="explain">
            云尘付运维人员收到差错处理申请后，将尽快处理。处理后的差错交易，会更新为已处理差错交易，并在“已处理差错”中进行展示。
          </div>
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="visible = false" style="width: 120px"
          >取消</el-button
        >
        <el-button type="primary" @click="submitFn" style="width: 120px"
          >确定</el-button
        >
      </span>
    </el-dialog>
  </div>
</template>

<script>
import mixin from "@/mixins/mixin";
import { getUserInfo } from "@/utils/public";

export default {
  name: "noApplication",
  mixins: [mixin],
  data() {
    return {
      rowItem: "",
      mixinViewModuleOptions: {
        getDataListURL: "/api/diffPayformData/searchLocalLostByPage",
        createdIsNeed: false,
      },
      visible: false,
      commandForm: {
        date: [],
        handleStatus: "",
      payformChannel:'',
      },
      payChannel: [],
      payChannelType: this.$store.state.channelListType,
      payChannelTypeList: [],
      dataList: [],
    };
  },
  created() {
    this.dataForm = JSON.parse(JSON.stringify(this.commandForm));
    this.handleQuery();
    this.getChannelList();
  },
  watch: {
    "$store.state.testLine": {
      handler() {
        if (this.$route.name == this.$options.name) {
          this.handleQuery();
        }
      },
    },
    deep: true,
  },
  methods: {
    getUserInfo,
    getChannelList() {
      this.$http.get("/api/dict/channelList").then((res) => {
        if (res.code === "0000") {
          var a = [{ label: "所有", value: "" }];
          var b = a.concat(res.data);
          this.payChannel = b;
        }
      });
    },
    submit(row) {
      this.visible = true;
      this.rowItem = row;
    },
    submitFn() {
      this.$http
        .put("/api/diffPayformData/submitWorkOrder", {
          id: this.rowItem.id,
        })
        .then((res) => {
          if (res.code == "0000") {
            this.$message.success("提交成功！");
            this.visible = false;
            this.getDataList();
          }
        });
    },
    handleQuery() {
      if (this.dataForm.date && this.dataForm.date.length) {
        this.dataForm.startDate = this.dataForm.date[0];
        this.dataForm.endDate = this.dataForm.date[1];
      } else {
        this.dataForm.startDate = "";
        this.dataForm.endDate = "";
      }
      this.getDataList();
    },
  },
};
</script>

<style scoped lang="scss">
.switch {
  margin-bottom: 20px;
}

.dialogText {
  display: flex;
  .dialogTitle {
    font-size: 20px;
    margin-bottom: 10px;
    font-weight: 500;
    color: rgba(0, 0, 0, 0.85);
    line-height: 24px;
  }
  .explain {
    color: rgba(0, 0, 0, 0.6);
    line-height: 22px;
    margin: 10px 0;
  }
}
:deep(.el-dialog) {
  border-radius: 16px;
  .el-dialog__header {
    padding: 0;
  }
  .el-icon-warning {
    font-size: 20px;
    color: #faad14;
    margin-top: 3px;
    margin-right: 17px;
  }
}
</style>
